<?php 
if(KT!='KhiThe') exit;
class contacts_controller extends contacts_model{
		
	public function __construct(){
		global $lang;
		$this->_layout = NULL;
		$lang['error_sms']='';
		$this->lang = $lang;
		parent::__construct();
		parent::addObject('khithe_template');
		parent::addObject('khithe_request');
		parent::addObject('khithe_string');
		parent::addObject('khithe_captcha');
	}
	
	public function index_action()
	{		
		$this->lang['error_sms'] = $this->lang['notEmpty'];
		if(isset($_POST['ispost']) && $_POST['ispost']=='ok'){
			
			if($_POST['Fullname']==''){
				$this->lang['error_sms'] = $this->lang['notEmptyFullname'];
				
			}else if($_POST['Email']==''){
				$this->lang['error_sms'] = $this->lang['notEmptyEmail'];
				
			}else if($_POST['Title']==''){
				$this->lang['error_sms'] = $this->lang['notEmptyTitle'];
				
			}else if($_POST['Content']==''){
				$this->lang['error_sms'] = $this->lang['notEmptyContent'];
			
			}else if($_POST['captcha']!=$_SESSION['Captcha'] || $_SESSION['Captcha']==''){
				$this->lang['error_sms'] = $this->lang['notEmptyCaptcha'];
			
			}else{
				
				parent::setCheckedcontact($_POST);
				parent::sms($this->lang['done']);
				parent::gotoload(url_base);		
			}
		}
		
		$this->lang['txtFullname'] = isset($_POST['Fullname'])?$_POST['Fullname']:NULL;
		$this->lang['txtAddress'] = isset($_POST['Address'])?$_POST['Address']:NULL;
		$this->lang['txtTelephone'] = isset($_POST['Telephone'])?$_POST['Telephone']:NULL;
		$this->lang['txtEmail'] = isset($_POST['Email'])?$_POST['Email']:NULL;
		$this->lang['txtTitle'] = isset($_POST['Title'])?$_POST['Title']:NULL;
		$this->lang['Content'] = isset($_POST['Content'])?$_POST['Content']:NULL;
		
		if(file_exists(path_app.'/admin/com_contacts/views/contacts.phtml')){
			$strcontact = stripslashes(file_get_contents(path_app.'/admin/com_contacts/views/contacts.phtml'));
		
		}
		$this->lang['str_contact'] = $strcontact;
		$strHtmlContent = $this->khithe_display('index');
		$strHtmlContent = $this->khithe_assign($strHtmlContent, $this->lang);


        $arrAction = array(
            'html'=>$strHtmlContent,
            'title_paper'=>$this->lang['title_paper'],
            'keywords'=>$this->lang['keywords'],
            'description'=>$this->lang['title_paper'],
            'SeoH1'=>$this->lang['SeoH1'],
            'SeoH2'=>$this->lang['SeoH2'],
            'SeoP'=>$this->lang['SeoP']
        );

        return $arrAction;

    }
	
	public function index_ajax_action()
	{
		$this->_layout = 'NOT';
		if($this->valUrl(1)=='img')
		{			
			return $this->showImage();
		}
	}


}
?>